package xyz.yzy.coc.myqqrobot.qqrebot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.forte.qqrobot.anno.Filter;
import com.forte.qqrobot.anno.Listen;
import com.forte.qqrobot.beans.messages.msgget.GroupMsg;
import com.forte.qqrobot.beans.messages.types.MsgGetTypes;
import com.forte.qqrobot.sender.MsgSender;
import com.forte.qqrobot.utils.CQCodeUtil;

import xyz.yzy.coc.myqqrobot.controller.QqRecordController;
import xyz.yzy.coc.myqqrobot.dao.Qqrobot;
import xyz.yzy.coc.myqqrobot.entity.QqRecord;
import xyz.yzy.coc.myqqrobot.service.QqRecordService;
@Listen(MsgGetTypes.groupMsg)
@Component
public class MyGroupMsgListenner {
	@Autowired
	private QqRecordService qqservice;
	@Filter()
	public void onMessage(GroupMsg msg , MsgSender msgsender,CQCodeUtil cqCodeUtil) {
		//保存到数据库
		QqRecord qqentity = new QqRecord();
		qqentity.setMsg(msg.getMsg());
		qqentity.setQqnumber(msg.getGroup());
		qqentity.setQunnumber(msg.getQQ());
		qqentity.setType(msg.getFont());
		qqentity.setTime(msg.getTime());
		qqservice.save(qqentity);
		//Qqrobot.bbb(msg);//调用jdbc保存
		System.out.println(msg.getMsg());
		System.out.println(msg.getType());
		if(msg.getGroup().equals("719190458")&&msg.getQQ().equals("936642284")) {
			msgsender.SENDER.sendGroupMsg(msg.getGroup(),cqCodeUtil.getCQCode_at(msg.getQQ())+msg.getMsg());
			System.out.println("输出成功");
		}
		/*QqRecordController qq = new QqRecordController();
		qq.tosave(msg);*/
	}
}
